import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

import Layout from '@/layout'
import Nested from './modules/nested';

const routes = [
  // 登录
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  // 404
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  // 首页
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'el-icon-s-home' }
    }]
  },
  // 多层菜单
  Nested,
  
  {
    path: '/table',
    component: Layout,
    redirect: '/table/index',
    children: [{
      path: 'index',
      name: 'Table',
      component: () => import('@/views/table/index'),
      meta: { title: '表格', icon: 'el-icon-s-data' }
    }]
  },
  // 非上述路由跳转404
  { path: '*', redirect: '/404', hidden: true }

]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
